using System;
using System.Collections.Generic;
using System.Text;

namespace Splino.DrawObject
{
    /// <summary>
    /// Houses the form and toolbar used by the user to
    /// initiate drawing of point and spline objects
    /// </summary>
    public class DrawManager
    {


        DrawToolbar _drawToolbar;
        /// <summary>
        /// The toolbar that contains the buttons to draw point
        /// and spline objects
        /// </summary>
        public DrawToolbar DrawToolbar
        {
            get { return _drawToolbar; }
        }

        bool _drawToolbarActive = false;
        /// <summary>
        /// Gets or sets whether or not the Draw Toolbar is visible
        /// </summary>
        public bool DrawToolbarActive
        {
            get { return _drawToolbarActive; }
            set { _drawToolbarActive = value; }
        }

        private static readonly object padlock = new object();
        private static volatile DrawManager _instance;
        /// <summary>
        /// The singleton instance of the Draw Manager
        /// </summary>
        public static DrawManager Instance
        {
            get
            {
                if (_instance == null)
                    lock (padlock)
                    {
                        if (_instance == null)
                            _instance = new DrawManager();
                    }
                return _instance;
            }
        }
        private DrawManager() { }

        /// <summary>
        /// Displays the DrawToolbar form
        /// </summary>
        public void ShowDrawToolbar()
        {
            if (!_drawToolbarActive)
            {
                _drawToolbar = new DrawToolbar();
                _drawToolbar.Show(SplinoForm.Instance);
                _drawToolbarActive = true;
            }
            else
                _drawToolbar.Show(SplinoForm.Instance);
        }
    }
}
